"use strict";
// pages/room/detail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    role:"",
    statussearch: 1,
    adviselist: [],
    approvetext: "",
    accounts: ["-选择-", "需求列表", "开发中", "开发完成","已上线","后续安排","暂不考虑","删除"]
  },
  refresh: function () {
    app.api.api_user_adviselist({ statussearch: this.data.statussearch}).then(res => {
      this.setData({ adviselist: res.adviselist, role:res.role})
    })
  },
  bindKeyInput: function (e) {
    this.data[e.currentTarget.dataset.obj] = e.detail.value
  },
  bindAccountChangeSearch:function(e){
    this.setData({
      statussearch: e.detail.value
    });
    this.refresh();
  },
  bindAccountChange: function (e) {
    console.log('picker account 发生选择改变，携带值为', e.detail.value, e.currentTarget.id);
    app.api.api_user_saveadvise({
      id:e.currentTarget.id,
      status: e.detail.value
    }).then(res => {
      this.refresh();
    })
  },
  submit: function () {
    app.api.api_user_saveadvise({
      approvetext: this.data.approvetext
    }).then(res => {
      this.setData({
        approvetext: ""
      });
      this.refresh();
    })
  },
  about:function(){
    // wx.navigateTo({
    //   url: '/+paper/pages/index/index',
    // })
  },

  /**
   * 生命周期函数--监听页面加载，设置userid
   */
  onLoad: function (options) {
    this.refresh()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.refresh()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let title = '筱薇课'
    if (this.data.info.name) {
      title += " - " + this.data.info.name
    }
    return {
      title: title,
      page: '/pages/user/adviseshow'
    }
  }
})